// pages/slide/deletitem.js
var that;


var App = getApp();

const items = [
  {
    name: "祁同伟",
    sex: "男",
    group: "组织",
    phone: "13111111111",
    shortNum: "13111111111",
    mail: "13111111111@189.com",
    unit: "汉东省公安厅",
    department: "汉东省公安厅",
    job: "公安厅厅长",
    function: "管理公安厅",
    comPhone: "13111111111",
    fax: "13111111111",
    homePhone: "13111111111",
    showOrder: "",
    departOrder: "",
    remark: "汉东省公安厅厅长"
  },
  {
    name: "欧阳菁",
    sex: "女",
    group: "群众",
    phone: "13222222222",
    shortNum: "13222222222",
    mail: "13222222222@189.com",
    unit: "京州银行",
    department: "京州银行",
    job: "京州银行行长",
    function: "管理京州银行",
    comPhone: "13222222222",
    fax: "13222222222",
    homePhone: "13222222222",
    showOrder: "",
    departOrder: "",
    remark: "京州银行行长"
  },
  {
    name: "陈岩石",
    sex: "男",
    group: "组织",
    phone: "13333333333",
    shortNum: "13333333333",
    mail: "13333333333@189.com",
    unit: "汉东省检察院",
    department: "汉东省检察院",
    job: "原察院检察长",
    function: "检察长",
    comPhone: "13333333333",
    fax: "13333333333",
    homePhone: "13333333333",
    showOrder: "",
    departOrder: "",
    remark: "原汉东省检察院检察长"
  },
  {
    name: "陆亦可",
    sex: "女",
    group: "组织",
    phone: "13555555555",
    shortNum: "13555555555",
    mail: "13555555555@189.com",
    unit: "汉东省反贪局一处",
    department: "汉东省反贪局一处",
    job: "处长",
    function: "管理一处",
    comPhone: "13555555555",
    fax: "13555555555",
    homePhone: "13555555555",
    showOrder: "",
    departOrder: "",
    remark: "汉东省反贪局一处处长"
  },
  {
    name: "林华华",
    sex: "女",
    group: "组织",
    phone: "13666666666",
    shortNum: "13666666666",
    mail: "13666666666@189.com",
    unit: "汉东省反贪局一处",
    department: "汉东省反贪局一处",
    job: "普通职员",
    function: "普通职员",
    comPhone: "13666666666",
    fax: "13666666666",
    homePhone: "13666666666",
    showOrder: "",
    departOrder: "",
    remark: "普通职员",
  },
  {
    name: "候亮平",
    sex: "男",
    group: "组织",
    phone: "13777777777",
    shortNum: "1377777777",
    mail: "13777777777@189.com",
    unit: "汉东省反贪局",
    department: "汉东省反贪局",
    job: "局长",
    function: "反贪",
    comPhone: "13777777777",
    fax: "13777777777",
    homePhone: "13777777777",
    showOrder: "",
    departOrder: "",
    remark: "汉东省反贪局局长"
  },
  {
    name: "孙连城",
    sex: "男",
    group: "组织",
    phone: "13555555555",
    shortNum: "13555555555",
    mail: "13555555555@189.com",
    unit: "光明区区长办公室",
    department: "光明区区长",
    job: "区长",
    function: "管理光明区",
    comPhone: "13555555555",
    fax: "13555555555",
    homePhone: "13555555555",
    showOrder: "",
    departOrder: "",
    remark: "光明区区长"
  },
  {
    name: "李达康",
    sex: "男",
    group: "组织",
    phone: "13555555555",
    shortNum: "13555555555",
    mail: "13555555555@189.com",
    unit: "京州市市委",
    department: "京州市市委",
    job: "市委书记",
    function: "管理京州市",
    comPhone: "13555555555",
    fax: "13555555555",
    homePhone: "13555555555",
    showOrder: "",
    departOrder: "",
    remark: "京州市市委书记"
  },
  {
    name: "高小琴",
    sex: "女",
    group: "群众",
    phone: "13555555555",
    shortNum: "13555555555",
    mail: "13555555555@189.com",
    unit: "山水庄园",
    department: "山水庄园",
    job: "总经理",
    function: "管理山水庄园",
    comPhone: "13555555555",
    fax: "13555555555",
    homePhone: "13555555555",
    showOrder: "",
    departOrder: "",
    remark: "管理山水庄园"
  },
]


Page({

  /**
   * 页面的初始数据
   */
  data: {
    items: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    that = this;
    
    /*模拟数据*/
    that.setData({
      items: items
    })

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  //手指触摸动作开始 记录起点X坐标
  touchstart: function (e) {
    //开始触摸时 重置所有删除
    let data = App.touch._touchstart(e, this.data.items)
    this.setData({
      items: data
    })
  },

  //滑动事件处理
  touchmove: function (e) {
    let data = App.touch._touchmove(e, this.data.items)
    this.setData({
      items: data
    })
  },

  //删除事件
  del: function (e) {
    wx.showModal({
      title: '提示',
      content: '确认要删除此条信息么？',
      success: function (res) {
        if (res.confirm) {
          console.log('用户点击确定')
          that.data.items.splice(e.currentTarget.dataset.index, 1)
          that.setData({
            items: that.data.items
          })
        } else if (res.cancel) {
          console.log('用户点击取消')
        }
      }
    })
  }
})